import requests
import json
import random
import math


def get_ship_fee(country, weight):
    ship_fee_map = {
        'VN': {'start': 20000, 'incr': 90}
    }
    return 0

def get_product_price_and_weight(product_id):
    rmb_price = random.randint(10, 100)
    weight = random.randint(100, 500)
    return [rmb_price, weight]

def get_yinliu_price(skus):
    for sku in skus:
        if sku['inventory_quantity'] == 10:
            return sku['sale_price']
    return 0    

def get_coupon_price(yinliu_price):
    return math.ceil(yinliu_price * 0.2)

def get_kill_price(sku, rmb_price, weight, exchange_rate):
    if sku['inventory_quantity'] == 10:
        return None
    else:
        return (rmb_price + 2.6) * 1.65 / exchange_rate + get_ship_fee(country, weight)

if __name__ == '__main__':
    country = 'VN'
    exchange_rate = 0.00029
    fees = {
        'yongjin': 3,     # 佣金
        'shouxu_fee': 5, # 手续费
        'sfp_fee': 6, # SFP项目费
        'added_tax_fee': 10, # 增值税
        'daren_fee': 10, # 达人佣金
    }

    product_ids = ['1732084954920028704', '1732084848202844704']
    for product_id in product_ids:
        skus = get_product_skus(product_id)
        yinliu_price = get_yinliu_price(skus)
        coupon_price = get_coupon_price(yinliu_price)
        rmb_price, weight = get_product_price_and_weight(product_id)
        print(f'产品ID: {product_id}')
        print(f'引流品价格: {yinliu_price}(汇率[{country}]: {exchange_rate})')
        print(f'采集价: {rmb_price}')
        print(f'优惠券价格: {coupon_price}')
        print(f'重量: {weight} g')
        for sku in skus:
            sku['weight'] = weight
            kill_price = get_kill_price(sku, rmb_price, weight, exchange_rate)
            print(sku)
        print('-' * 100)